package com.glgc.projecti.common;


public class BizException extends Exception {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1499536304606613671L;
  
	/**
	 * 错误码
	 */
	private String errCode;

	/**
	 * 错误信息
	 */
	private String errInfo;

	/**
	 * 打印的内容
	 */
	private String printMessage;

	/**
	 * @param errInfo
	 */
	public BizException(String errInfo) {
		this(CommonConstant.ERROR, errInfo, null);
	}

	/**
	 * @param errInfo
	 */
	public BizException(String errInfo, String printMessage) {
		this(CommonConstant.ERROR, errInfo, printMessage);
	}

	/**
	 * @param errCode
	 * @param errInfo
	 */
	public BizException(String errCode, String errInfo, String printMessage) {
		this.errCode = errCode;
		this.errInfo = errInfo;
		this.printMessage = printMessage;
	}
	
	/**
	 * 
	 * @param errCode
	 * @param errInfo
	 * @param printMessage
	 * @param cause
	 */
	public BizException(String errCode, String errInfo, String printMessage,Throwable cause) {
		super(cause);
		this.errCode = errCode;
		this.errInfo = errInfo;
		this.printMessage = printMessage;
	}

	/**
	 * @param message
	 * @param cause
	 */
	public BizException(String errInfo, Throwable cause) {
		super(cause);
		this.errCode = CommonConstant.ERROR;
		this.errInfo = errInfo;
	}

	/**
	 * @return the errCode
	 */
	public String getErrCode() {
		return errCode;
	}

	/**
	 * @return the errInfo
	 */
	public String getErrInfo() {
		return errInfo;
	}

	/**
	 * @return the printMessage
	 */
	public String getPrintMessage() {
		return printMessage;
	}

	/* (non-Javadoc)
	 * @see java.lang.Throwable#getMessage()
	 */
	@Override
	public String getMessage() {
		if(CommonUtils.isEmpty(getPrintMessage())) return getErrInfo()+super.getMessage();
		return getErrInfo()+getPrintMessage();
	}
}
